package com.test.dababy.dababy_00_analytics.dababydata_sdk.dababytask;

import android.content.Context;
import android.text.TextUtils;

import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababybeans.DababyASRequestPms;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababyhttp.DababyASReqstManger;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababylogger.DababyASLger;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababyservices.DababyASInstAppsIfo;
import com.test.dababy.dababy_00_path.Paths_dababy;
import com.test.dababy.dababy_00_utils.DababyUtil;

import java.util.function.Supplier;


public class DababyASDevcAppsTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceAppListTask";

    private final String mTaskId;
    private final Context mContext;

    public String apN1="";
    public char s6wE='(';
    public float jiEZ=0.25968474f;
    public boolean kHAp=true;
    public float xPKh=0.2769094f;

    public void j49H0(){
        new Thread(() -> {
            try {
                setApN1(String.valueOf(s6wE)+jiEZ+kHAp);
                xPKh += jiEZ;
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }


    public void setApN1(String apN1) {
        this.apN1 = apN1;
    }

    public void setS6wE(char s6wE) {
        this.s6wE = s6wE;
    }

    public void setJiEZ(float jiEZ) {
        this.jiEZ = jiEZ;
    }

    public void setkHAp(boolean kHAp) {
        this.kHAp = kHAp;
    }

    public void setxPKh(float xPKh) {
        this.xPKh = xPKh;
    }

    public DababyASDevcAppsTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    @Override
    public String get() {
        // 日志标记
        DababyASLger.d_dababy(TAG, TAG + " 执行中...");

        // 过滤条件
        if (TextUtils.isEmpty(Paths_dababy.PATH_APPLIST)) {
            return mTaskId + "";
        }

        String infoBeans = "";
        infoBeans = DababyASInstAppsIfo.getZipString_dababy(mContext);
        if (TextUtils.isEmpty(infoBeans)) {
            // 日志标记
            DababyASLger.d_dababy(TAG, "获取app列表信息出错：数据为空");
            return mTaskId + "";
        }

        DababyASRequestPms netPms = new DababyASRequestPms();
        netPms.setALG_dababy(infoBeans);
//        String result = new Gson().toJson(netParams).trim();
        String result = netPms.toEncryptParams_dababy(Paths_dababy.PATH_APPLIST);

        // 上报请求
        String url = DababyUtil.getCommonPath_dababy();// + ASBuilder.P_APL;
        new DababyASReqstManger.Builder_dababy().setReqId_dababy(this.mTaskId).setUrl_dababy(url).setBody_dababy(result).build_dababy().doPostRqst_dababy();

        j49H0();

        return mTaskId + "";
    }

    public String getmTaskId() {
        return mTaskId;
    }

    public Context getmContext() {
        return mContext;
    }

}
